<template>
	<el-drawer title="新闻详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container>
			<el-main>
				<el-header style="display: block;text-align: center">
					<div style="text-align: center;display: inline;font-weight: 600;font-size: 16px">
						{{ form.newsTitle }}
					</div>
				</el-header>
				<el-main>
					<span v-html="form.content"></span>
					<div style="margin-top: 20px;text-align: right;">
							<div style="float: left;">
								【{{ form.newsTypeName }}】{{ form.createUser }}
							</div>
						<span>点击：{{ form.onclickCount }}次</span><span style="margin-left: 20px">发布时间：{{ form.createTime }}</span>
					</div>
				</el-main>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>
<script>
export default {
	name: 'News Details',
	data() {
		return {
			form: {
				createUser: '',
				newsTitle: '',
				newsTypeName: '',
				onclickCount: 0,
				content:'',
				createTime: '',
			},
			model:"read",
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {
	},
	methods: {
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},
		setData(data){
			this.form.createUser=data.createUser
			this.form.newsTypeName =data.newsTypeName
			this.form.newsType=data.newsType
			this.form.content = data.content
			this.form.newsTitle = data.newsTitle
			this.form.onclickCount=data.onclickCount
			this.form.createTime=data.createTime
			if(this.model!='setting')
			{
				this.setNewsReadStatus(data.newsId);
			}
		},
		async setNewsReadStatus(newsId)
		{
			await this.$API.info.news.setNewsReadStatus.post({newsId:newsId});
		},
		async getMyNewsById(data)
		{
			let res = await this.$API.info.news.getMyNewsById.get({newsId:data});
			{
				if(res.code==200)
				{
					this.form.createUser=res.data.createUser
					this.form.newsTypeName =res.data.newsTypeName
					this.form.newsType=res.data.newsType
					this.form.content = res.data.content
					this.form.newsTitle = res.data.newsTitle
					this.form.onclickCount=res.data.onclickCount
					this.form.createTime=res.data.createTime
					this.setNewsReadStatus(data);
				}else
				{
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}
	}

}
</script>

<style>
</style>
